'''
    a3mall业务
'''
import logging

from month_8_8.Page.Page import Page
from month_8_8.Page.Page1 import Page1
from month_8_8.Page.Page2 import Page2
from selenium import webdriver
import pytest,yaml
from month_8_8.Tools.Tools import Tools
def data():
    with open(r'C:\Users\张震海\Desktop\month_1\month_8_8\a3mall.yaml',encoding='utf-8') as f:
        return yaml.safe_load(f)
@pytest.fixture
def driver():
    driver = webdriver.Edge()
    Tools().log()
    # 隐式等待
    driver.implicitly_wait(10)
    yield driver
    driver.quit()
class Test_case():
    @pytest.mark.parametrize('data',data())
    def test_a3mall_login_001(self,driver,data):
        username = data.get('username')
        password = data.get('password')
        po = Page(driver)
        logging.debug('a3mall_login_001')
        po.a3mall_login_001()
        logging.debug('a3mall_login_001')
        po.a3mall_login_002(username)
        logging.debug('a3mall_login_001')
        po.a3mall_login_003(password)
        print(data.get('exp'))

    @pytest.mark.parametrize('data', data())
    def test_a3mall_search_002(self, driver, data):
        username = data.get('username')
        password = data.get('password')
        if username=='19064013675' and password=='123456':
            po = Page1(driver)
            po.a3mall_search_002()
            logging.debug('login')
            po.a3mall_login_004(username)
            logging.debug('search')
            po.a3mall_login_005(password)
            driver.close()

    @pytest.mark.parametrize('data', data())
    def test_a3mall_gwc_003(self, driver, data):
        username = data.get('username')
        password = data.get('password')
        if username == '19064013675' and password == '123456':
            po = Page2(driver)
            po.a3mall_gwc_003()
            logging.debug('login')
            po.a3mall_login_006(username)
            logging.info('gwc')
            po.a3mall_login_007(password)

if __name__ == '__main__':
    pytest.main()